package com.onadake.domain.query;

import java.util.Map;

/**
 * This interface defines required functionality to be able convert criterium
 * to the map where keys and values are type of String and back.
 * 
 * @author radek.hecl
 *
 * @param <ColumnType> type of the column used in criterium
 */
public interface CriteriumStringMapConverter<ColumnType> {

    /**
     * Encodes one criterium as a map of string keys and values.
     * 
     * @param criterium criterium to be encoded
     * @return map with encoded criterium. Allowed keys are column, operator and value*.
     *      Where * means any string. Therefore there can be one or more than one value keys (e.g. value[0], value[1]...).
     */
    public Map<String, String> encode(Criterium<ColumnType> criterium);
    
    /**
     * Decodes criterium from the specified map.
     * 
     * @param map map with encoded criterium. Keys are column, operator and value*.
     *      Where * means any string. Therefore there can be one or more than one value keys (e.g. value[0], value[1]...).
     * @return decoded criterium
     */
    public Criterium<ColumnType> decode(Map<String, String> map);
    
}
